import { Asset, SpriteFrame, resources } from 'cc'
import { ITile } from '../Levels'

class BattleData {
  allSpriteFrame: Array<SpriteFrame> = []

  mapInfo: Array<Array<ITile>>
  rowCount: number
  colCount: number
  TILE_WIDTH: number = 55
  TILE_HEIGHT: number = 55
  levelIndex: number = 1

  getSpriteFramesByPath(path: string) {
    const pathList = resources.getDirWithPath('texture').filter(i => i.path.includes(path))
    const res = this.allSpriteFrame.filter(i => {
      return pathList.find(j => j.uuid === i._uuid)
    })
    return res
  }

  reset() {
    this.mapInfo = []
    this.rowCount = 0
    this.colCount = 0
  }
}

export const DataCenter = new BattleData()
